#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP

#include <QMainWindow>
#include <QFileDialog>
#include <QDebug>
#include <QMessageBox>
#include <QLabel>

#include "codeview.hpp"
#include "breakpoints.hpp"
#include "inputbuttonview.hpp"
#include "ledview.hpp"
#include "papview.hpp"
#include "registerview.hpp"
#include "sevensegmentview.hpp"
#include "stackview.hpp"
#include "watchlist.hpp"
#include "appsettings.hpp"
#include "pix.hpp"
#include "hardwareinterfaceview.hpp"

class Pix;
class CodeView;
class PapView;

namespace Ui {
    class MainWindow;
}

/**
* @brief
*
* @class MainWindow mainwindow.hpp "mainwindow.hpp"
*/
class MainWindow : public QMainWindow {
    Q_OBJECT
public:
    /**
    * @brief
    *
    * @fn MainWindow
    * @param parent
    */
    MainWindow(QWidget *parent = 0);

    /**
    * @brief
    *
    * @fn ~MainWindow
    */
    ~MainWindow();

    /**
    * @brief
    *
    * @fn closeEvent
    * @param
    */
    void closeEvent(QCloseEvent *);

    /**
    * @brief Resets the Registers and the Program Counter after a Watchdog Timeout
    *
    * @fn resetAfterWatchdogTimeout
    */
    void resetToProgramStart();

protected:
    /**
    * @brief
    *
    * @fn changeEvent
    * @param e
    */
    void changeEvent(QEvent *e);

private:
    Ui::MainWindow *ui;
    CodeView *codeView;
    Breakpoints *breakpointView;
    PapView *papView;
    RegisterView *registerView;
    StackView *stackView;
    WatchList *watchList;
    AppSettings *appSettings;
    QMessageBox *msgBoxWatchdogTimeout;
    Pix *pix;
    HardwareInterfaceView *hwInterfaceView;
    QLabel *runtime;
    QLabel *watchdog;
    QLabel *information;

private slots:
    /**
    * @brief Triggered when actionOpen comes up
    * @details File->Open
    *
    * @fn on_actionOpen_triggered
    */
    void on_actionOpen_triggered();

    /**
    * @brief Triggered when actionNew comes up
    * @details File->New
    *
    * @fn on_actionNew_triggered
    */
    void on_actionNew_triggered();

    /**
    * @brief Triggered when actionClose comes up
    * @details File->Close
    *
    * @fn on_actionClose_triggered
    */
    void on_actionClose_triggered();

    /**
    * @brief Triggered when actionStart comes up
    *
    * @fn on_actionStart_triggered
    */
    void on_actionStart_triggered();

    void on_actionStop_triggered();

    void on_actionTrace_triggered();

    void on_actionPause_triggered();

    void onWatchdogTimeout();

    void on_actionFastMode_toggled(bool state);

    void updateStatusbar();

    void onCodeFileParsed();

    void onSimulationStateChanged(bool state);

    void onRequestChangeRegister(int address, int value);

    void onManualSend();
    void onManualReceive(QString data);

signals:
    void reset();
    void start();
    void stop();
    void pause();
    void trace();
    void parseLstFile(QString filename);
    void requestChangeBank(bool);

};

#endif // MAINWINDOW_HPP
